import java.util.HashMap;


class P10415_39643 {

	public static void main(String[] args) {
		int cases = Integer.parseInt(readLn());
		
//	    * c: finger 2~4, 7~10
//	    * d: finger 2~4, 7~9
//	    * e: finger 2~4, 7, 8
//	    * f: finger 2~4, 7
//	    * g: finger 2~4
//	    * a: finger 2, 3
//	    * b: finger 2
//	    * C: finger 3
//	    * D: finger 1~4, 7~9
//	    * E: finger 1~4, 7, 8
//	    * F: finger 1~4, 7
//	    * G: finger 1~4
//	    * A: finger 1~3
//	    * B: finger 1~2 
		
		HashMap<Character, boolean[]> map = new HashMap<Character, boolean[]>();
		
		map.put('c', new boolean[] {false, false, true, true, true, false, false, true, true, true, true}); 
		map.put('d', new boolean[] {false, false, true, true, true, false, false, true, true, true, false });
		map.put('e', new boolean[] {false, false, true, true, true, false, false, true, true, false, false});
		map.put('f', new boolean[] {false, false, true, true, true, false, false, true, false, false, false });
		map.put('g', new boolean[] {false, false, true, true, true, false, false, false, false, false, false});
		map.put('a', new boolean[] {false, false, true, true, false, false, false, false, false, false, false});
		map.put('b', new boolean[] {false, false, true, false, false, false, false, false, false, false, false });
		map.put('C', new boolean[] {false, false, false, true, false, false, false, false, false, false, false });
		map.put('D', new boolean[] {false, true, true, true, true, false, false, true, true, true, false});
		map.put('E', new boolean[] {false, true, true, true, true, false, false, true, true, false, false});
		map.put('F', new boolean[] {false, true, true, true, true, false, false, true, false, false, false});
		map.put('G', new boolean[] {false, true, true, true, true, false, false, false, false, false, false });
		map.put('A', new boolean[] {false, true, true, true, false, false, false, false, false, false, false});
		map.put('B', new boolean[] {false, true, true, false, false, false, false, false, false, false, false});
		
		for (int k = 0; k < cases; k++) {
			int[] fingers = new int[11];
			boolean[] pressing = new boolean[11];
			String line = readLn();
			
			for (int j = 0; j < line.length(); j++) {
				boolean[] fingersToPress = map.get(line.charAt(j));
//				int fingerCount = 0;
				for (int i = 1; i < fingersToPress.length; i++) {
					if (pressing[i] && !fingersToPress[i]) pressing[i] = false;
					if (fingersToPress[i] && !pressing[i]) {
						pressing[i] = true;
						fingers[i]++;
					}
				}
				
			}
			
			StringBuilder sb = new StringBuilder();
			for (int i = 1; i < fingers.length; i++) sb.append(fingers[i] + " ");
			System.out.println(sb.toString().trim());
			
		}
		
	}
	
	static String readLn() {
		String newLine = System.getProperty("line.separator");
		StringBuilder buffer = new StringBuilder();
		int car = -1;
		try {
			car = System.in.read();
			while ((car > 0) && (car != newLine.charAt(0))) {
				buffer.append((char) car);
				car = System.in.read();
			}
			if (car == newLine.charAt(0))
				System.in.skip(newLine.length() - 1);
		} catch (java.io.IOException e) {
			return (null);
		}
		if ((car < 0) && (buffer.length() == 0))
			return (null);
		return (buffer.toString());
	}
	
}
